package com.medical.mapi.web.controller;

import com.medical.mapi.JSONResult;
import com.medical.mapi.model.User;
import com.medical.mapi.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by junzi on 2016/10/17.
 */
@Api(value = "用户相关的接口")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation(notes = "用户列表", value = "返回用户集合", httpMethod = "GET")
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public JSONResult index() {
        return new JSONResult(userService.findAllList());
    }


    @ApiOperation(notes = "用户信息", value = "返回单个用户", httpMethod = "GET")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public JSONResult findById(@PathVariable Long id) {
        return new JSONResult(userService.findById(id));
    }
}
